package com.exam.service.serviceImpl;

import com.exam.dataobject.ExaminationContent;
import com.exam.repository.ExaminationContentRepository;
import com.exam.service.ExaminationContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by v
 * Date:2019/1/16
 * Time:17:15
 */
@Service
public class ExaminationContentServiceImpl implements ExaminationContentService {

    @Autowired
    private ExaminationContentRepository examinationContentRepository;

    @Override
    public void setExaminationContent(Integer examinationId, Integer[] questionId) {

        List<ExaminationContent> examinationContentList = new ArrayList<>();
        for (Integer i = 0; i < questionId.length; i++){
            ExaminationContent examinationContent = new ExaminationContent();
            examinationContent.setExaminationId(examinationId);
            examinationContent.setQuestionId(questionId[i]);
            examinationContentList.add(examinationContent);
        }
        examinationContentRepository.saveAll(examinationContentList);
    }
}
